package cn.wp.common.core.plugin.scheduler;

import cn.hutool.core.collection.CollectionUtil;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 调度容器
 * Created by chenyb on 2019/10/23
 */
public class SchedulerContainer {

    // 任务容器
    private Map<String,SchedulerTask> taskMap = new ConcurrentHashMap<String,SchedulerTask>();

    public Map<String,SchedulerTask> getTaskMap(){
        return taskMap;
    }

    public void addTask(String taskId,SchedulerTask schedulerTask){
        taskMap.put(taskId,schedulerTask);
    }

    public void updateTask(String taskId,SchedulerTask schedulerTask){
        taskMap.replace(taskId,schedulerTask);
    }

    public boolean containsTask(String taskId){
        return taskMap.containsKey(taskId);
    }

    public SchedulerTask getTask(String taskId){
        return taskMap.get(taskId);
    }

    public SchedulerTask removeTask(String taskId){
        return taskMap.remove(taskId);
    }


}
